Download and data check

network <- riem_networks()

co_stations <- riem_stations(network = "CO_ASOS") %>%
  st_as_sf(., coords=c('lon', 'lat'), crs=4326)

glimpse(co_stations)
## Rows: 73
## Columns: 27
## $ index         <int> 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16~
## $ id            <chr> "AFF", "AKO", "ALS", "ASE", "0CO", "BDU", "BJC", "BKF", ~
## $ synop         <dbl> 93065, 24015, 23061, 93073, 419, 160, 3065, 23036, 3064,~
## $ name          <chr> "AIR FORCE ACADEMY", "AKRON/WASHINGTON CO", "ALAMOSA MUN~
## $ state         <chr> "CO", "CO", "CO", "CO", "CO", "CO", "CO", "CO", "CO", "C~
## $ country       <chr> "US", "US", "US", "US", "US", "US", "US", "US", "US", "U~
## $ elevation     <dbl> 2003.000, 1431.000, 2299.000, 2382.000, 3792.000, 1612.0~
## $ network       <chr> "CO_ASOS", "CO_ASOS", "CO_ASOS", "CO_ASOS", "CO_ASOS", "~
## $ online        <lgl> TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TR~
## $ county        <chr> "El Paso", "Washington", "Alamosa", "Gunnison", "Clear C~
## $ climate_site  <chr> "COTCOS", "CO0114", "CO0130", "CO1959", "CO1186", "CO084~
## $ wfo           <chr> "PUB", "BOU", "PUB", "GJT", "BOU", "BOU", "BOU", "BOU", ~
## $ modified      <chr> "2021-05-05T10:48:22Z", "2021-05-05T10:48:22Z", "2021-05~
## $ spri          <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,~
## $ tzname        <chr> "America/Denver", "America/Denver", "America/Denver", "A~
## $ iemid         <int> 34687, 34688, 34689, 9415, 22652, 22664, 9436, 21855, 90~
## $ archive_begin <chr> "1967-11-27T17:00:00Z", "1948-01-01T07:00:00Z", "1948-01~
## $ metasite      <lgl> FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, ~
## $ ugc_county    <chr> "COC041", "COC121", "COC003", "COC097", "COC019", "COC01~
## $ ugc_zone      <chr> "COZ226", "COZ249", "COZ070", "COZ203", "COZ034", "COZ23~
## $ ncdc81        <chr> "USC00055734", "USW00024015", "USW00023061", "USW0009307~
## $ ncei91        <chr> "USC00050756", "USW00024015", "USW00023061", "USW0009307~
## $ longitude     <dbl> -104.8128, -103.2220, -105.8614, -106.8689, -105.7639, -~
## $ latitude      <dbl> 38.96972, 40.17563, 37.43889, 39.22317, 39.79388, 40.039~
## $ plot_name     <chr> NA, NA, NA, NA, "Bethoud Pass", "Boulder", NA, NA, "BUEN~
## $ archive_end   <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, ~
## $ geometry      <POINT [°]> POINT (-104.8128 38.96972), POINT (-103.222 40.175~
write.csv(co_stations,"Data/raw/co_stations.csv",row.names=F,na="")

Interactive map

# mapview(co_stations)

# Download some state boudary data

co_count <- us_counties(states = "Colorado")

co_elev <- elevatr::get_elev_raster(co_stations, z=9)
## Mosaicing & Projecting
## Note: Elevation units are in meters.
mapview(co_count) + mapview(co_elev) + mapview(co_stations)
## Warning in rasterCheckSize(x, maxpixels = maxpixels): maximum number of pixels for Raster* viewing is 5e+05 ; 
## the supplied Raster* has 19299420 
##  ... decreasing Raster* resolution to 5e+05 pixels
##  to view full resolution set 'maxpixels =  19299420 '

Static map

tm_shape(co_count) + tm_polygons(col='white') + tm_shape(co_stations) + tm_bubbles(size=0.2, col='red')

Download a single site data and analyze the precipitation

fnl <- riem_measures(station = 'FNL',
                   date_start = '1987-05-01',
                   date_end = '2000-05-01')
## Warning in scan(file = file, what = what, sep = sep, quote = quote, dec = dec, :
## EOF within quoted string
daily <- fnl %>%
  mutate(date = as.Date(valid)) %>%
  group_by(date) %>%
  summarize(daily_rain = mean(p01i*24,na.rm=T))

ggplot(daily, aes(x=date, y = daily_rain)) + 
  geom_point() +
  scale_y_log10() +
  labs(x="Year", y="Daily rain (inch)", title = "Daily Rain of Fort Collins")
## Warning: Removed 3421 rows containing missing values (geom_point).